import java.util.HashMap;
import java.util.Map;

public class Solution3 {
    public int[] twoSum(int[] nums, int target) {
        Map<Integer,Integer> map = new HashMap();
        for (int i = 0; i < nums.length; i++) {
            map.put(nums[i],i);
        }
        for (int i = 0; i < nums.length; i++) {
            int other = target - nums[i];
            if(map.containsKey(other) && map.get(other) != i){
               return new int[]{i,map.get(other)};
            }
        }
        return new int[]{};
    }

    public static void main(String[] args) {
        Solution3 s = new Solution3();
        int[] nums = {3,2,4};
        int[] a = s.twoSum(nums,6);
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i]);
        }
    }
}
